<?php

declare (strict_types=1);
namespace App\Model;

use App\Constants\Constant;
use Hyperf\DbConnection\Model\Model;
/**
 * @property int $new_id 
 * @property string $uri
 * @property string $title
 * @property string $content 
 * @property int $resource_type 
 * @property string $add_time 
 */
class News extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'news';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['uri','title','content','resource_type'];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['new_id' => 'integer', 'resource_type' => 'integer'];

    public $timestamps = false;

    protected $primaryKey = "new_id";

    public function resources(){
        return $this->hasMany(Resource::class,'source_id','new_id')->where("origin",Constant::ORIGIN_NEWS);
    }
}